package real.lang;

import java.util.Collection;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import real.lang.reflect.EnumerationOfRealSubtypes;
import real.lang.reflect.EnumerationOfRealTypes;
import real.lang.reflect.RealRTI;
import real.lang.reflect.RealType;
import real.lang.reflect.RealTypeSignature;

public class FiniteSet extends RealSet implements Set<RealObject> {

	public FiniteSet(RealType type) {
		super(type);
	}
	public FiniteSet() throws RealLangException {		
		super(RealRTI.getInstance().GetType(getRealTypeSignature(RealRTI.DEFAULT_TYPE_SPACE)));
	}	
	
	private Set<RealObject> internal = new HashSet<RealObject>();
	
	public static RealTypeSignature getRealTypeSignature(String typeSpace) {
		RealTypeSignature signature = new RealTypeSignature(
				EnumerationOfRealTypes.SET, 
				EnumSet.of(EnumerationOfRealSubtypes.FINITE), typeSpace);
		return signature;
	}
	
	public boolean add(RealObject e) {
		return this.internal.add(e);		
	}

	public boolean addAll(Collection<? extends RealObject> c) {
		return this.addAll(c);		
	}

	public void clear() {
		this.internal.clear();		
	}

	public boolean contains(Object o) {
		return this.internal.contains(o);
	}

	public boolean containsAll(Collection<?> c) {
		return this.internal.containsAll(c);
	}

	public boolean isEmpty() {
		return this.internal.isEmpty();
	}

	public Iterator<RealObject> iterator() {
		return this.internal.iterator();
	}

	public boolean remove(Object o) {
		return this.internal.remove(o);
	}

	public boolean removeAll(Collection<?> c) {
		return this.internal.removeAll(c);
	}

	public boolean retainAll(Collection<?> c) {	
		return this.internal.retainAll(c);
	}

	public int size() {
		return this.internal.size();
	}

	public Object[] toArray() {	
		return this.toArray();
	}

	public <T> T[] toArray(T[] a) {
		return this.internal.toArray(a);		
	}

}
